package com.duobaoyu.dby.supply.job.task.supply;

import com.duobaoyu.dby.common.core.constant.CommonConstants;
import com.duobaoyu.dby.common.core.constant.StringPool;
import com.duobaoyu.dby.supply.biz.client.resource.ResourceApiClient;
import com.xxl.job.core.context.XxlJobHelper;
import com.xxl.job.core.handler.annotation.XxlJob;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.StringUtils;
import org.springframework.stereotype.Component;

/**
 * @author liyang
 * @version 1.0.0
 * @ClassName SupplyAddressSimilarityTask
 * @Description 地址相似度数据刷新
 * @createTime 15:18:00 2023/06/27
 */
@Slf4j
@Component
@RequiredArgsConstructor
public class SupplyAddressSimilarityTask{

    private final ResourceApiClient resourceApiClient;

    /**
     * 刷绑定地址相似度任务
     */
    @XxlJob("addressSimilarityJobHandler")
    public void addressSimilarityJobHandler() {
        String param = XxlJobHelper.getJobParam();
        String channelCode = null;
        Integer similarity = null;
        if(StringUtils.isNotBlank(param)) {
            String[] split = param.split(StringPool.COMMA);
            channelCode = split[CommonConstants.ZERO];
            if(split.length > CommonConstants.ONE) {
                similarity = Integer.valueOf(split[CommonConstants.ONE]);
            }
        }
        resourceApiClient.addressBindSimilarity(channelCode,similarity);
    }
}
